


//
//  ZHCollectionVCell.swift
//  999999新浪微博
//
//  Created by 陈华 on 15/12/18.
//  Copyright © 2015年 华锐. All rights reserved.
//

import UIKit

class ZHCollectionVCell: UICollectionViewCell {
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView.addSubview(pictureView)
        contentView.addSubview(beginBnt)
        beginBnt.hidden = true 
        prepareUI()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    ///准备UI
    func prepareUI(){
        
        pictureView.translatesAutoresizingMaskIntoConstraints = false
        beginBnt.translatesAutoresizingMaskIntoConstraints = false
        addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: contentView, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0))
        addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: contentView, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0))
        addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Leading, relatedBy: NSLayoutRelation.Equal, toItem: contentView, attribute: NSLayoutAttribute.Leading, multiplier: 1, constant: 0))
        addConstraint(NSLayoutConstraint(item: pictureView, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: contentView, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: 0))
        
        addConstraint(NSLayoutConstraint(item: beginBnt, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: contentView, attribute: NSLayoutAttribute.CenterX, multiplier: 1, constant: 0))
        addConstraint(NSLayoutConstraint(item: beginBnt, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: contentView, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: -120))
    }
    
    ///按钮点击的方法
    func bntClilk(){
        print("33333333")
    }

    
    //MARK:懒加载
    lazy var pictureView: UIImageView = {
        let picture = UIImageView()
        return picture
    }()
    
    lazy var beginBnt: UIButton = {
        let bnt = UIButton(type: UIButtonType.Custom)
        bnt.setBackgroundImage(UIImage(named: "new_feature_finish_button_highlighted"), forState: UIControlState.Highlighted)
        bnt.setBackgroundImage(UIImage(named: "new_feature_finish_button"), forState: UIControlState.Normal)
        bnt.setTitle("开始体验", forState: UIControlState.Normal)
        bnt.addTarget(self, action: "bntClilk", forControlEvents: UIControlEvents.TouchUpInside)
        return bnt
    }()
}











